// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial

import { ListView  } from "std-widgets.slint";

TestCase := Window {
    width: 400px;
    height: 540px;

    property <string> value;

    listview := ListView {
        for data in [
            { text: "Blue", color: #0000ff, bg: #eeeeee},
            { text: "Red", color: #ff0000, bg: #eeeeee},
            { text: "Green", color: #00ff00, bg: #eeeeee},
            { text: "Yellow", color: #ffff00, bg: #222222 },
            { text: "Black", color: #000000, bg: #eeeeee },
            { text: "White", color: #ffffff, bg: #222222 },
            { text: "Magenta", color: #ff00ff, bg: #eeeeee },
            { text: "Cyan", color: #00ffff, bg: #222222 },
        ] : delegate := Rectangle {
            background: @linear-gradient(90deg, data.bg,data.bg.brighter(0.5));
            HorizontalLayout {
                text_Name := Text {
                    height: 100px;
                    text: data.text;
                    color: data.color;
                    font_size: 20px ;
                }
            }
            TouchArea { clicked => { value = data.text; } }
        }
    }
}

/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
slint_testing::send_mouse_click(&instance, 5., 205.);
assert_eq(instance.get_value(), "Green");
```

```rust
let instance = TestCase::new().unwrap();
slint_testing::send_mouse_click(&instance, 5., 205.);
assert_eq!(instance.get_value(), "Green");
```

```js
var instance = new slint.TestCase();
instance.send_mouse_click(5., 205.);
assert.equal(instance.value, "Green");
```

*/
